#include "choosescene.h"
#include "config.h"
#include "mypushbutton.h"
#include <QPainter>

//是否有限选关
bool ChooseScene::isLimit = false;


ChooseScene::ChooseScene(QWidget *parent)
    : QWidget{parent}
{
    //初始化窗口大小
    setFixedSize(GAME_WIDTH,GAME_HEIGTH);

    //设置窗口标题
    setWindowTitle(GAME_TITLE);

    //加载图标
    setWindowIcon(QIcon(GAME_ICON));

    //创建关卡场景
    this->playscene = new PlayScene;

    //创建有限选关按钮
    MyPushButton* startBtn30 = new MyPushButton(START_BTN_30);
    startBtn30->setParent(this);
    startBtn30->move((this->width()-startBtn30->width())*0.5,this->height()*0.25);
    connect(startBtn30,&MyPushButton::clicked,[=](){
        //qDebug()<<"进入开始场景";

        //限制有限选关
        isLimit = true;

        this->playscene->show();//游戏场景显示
        this->hide();//自身隐藏
    });

    //创建无限选关按钮
    MyPushButton* startBtn_infinite = new MyPushButton(START_BTN_INFINITE);
    startBtn_infinite->setParent(this);
    startBtn_infinite->move((this->width()-startBtn30->width())*0.5,this->height()*0.5);
    connect(startBtn_infinite,&MyPushButton::clicked,[=](){
        //qDebug()<<"进入开始场景";

        //无限
        isLimit = false;

        this->playscene->show();//游戏场景显示
        this->hide();//自身隐藏
    });

}

void ChooseScene::paintEvent(QPaintEvent *)
{
    QPainter painter(this);
    QPixmap pix;
    pix.load(CHOOSE_PATH);
    painter.drawPixmap(0,0,this->width(),this->height(),pix);
}
